package top.qingyunge.autumn.config;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serial;
import java.io.Serializable;
import java.util.Date;

@Data
public class BaseEntity implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;
    @TableId(type = IdType.AUTO)
    private Integer id;

    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")//存到数据库
    @JsonFormat(timezone = "UTC", pattern = "yyyy-MM-dd HH:mm:ss") //从数据库读出
    @TableField(fill = FieldFill.INSERT)
    private Date createTime;

    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")//存到数据库
    @JsonFormat(timezone = "UTC", pattern = "yyyy-MM-dd HH:mm:ss") //从数据库读出
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;

    @TableLogic(value = "0", delval = "1")
    private Integer isDeleted;
}
